home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / KMAGV3.ZIP / WAVEEXAM.PAS < prev    next >
Pascal/Delphi Source File  |  1996-01-11  |  3KB  |  88 lines

  1. {WAVEEXAM.PAS / EXAMPLE FOR A WAVES EFFECT}
  2. {WRITING BY THE KING IN 01/06/96          }
  3.  
  4. Uses KMagUnit;
  5. Const
  6.     Waves = 3;       {Number of waves}
  7.     SinWaves = 5;    {Depth of waves}
  8. Var
  9.     Y,T,T1 : Integer;
  10.  
  11.     SinT,CosT:Array[0..360] Of ShortInt; {Sin Cosin tables}
  12.     Pic : PicTypeP;                      {Picture}
  13.     Pal : PalType;                       {Palette}
  14.  
  15.  
  16. {-------------------------------------------------}
  17. {        Make a Sin/Cos Tables of Shortint        }
  18. {-------------------------------------------------}
  19. Procedure MakeSinCos;
  20. Var
  21.   T:Integer;
  22.   Begin
  23.     For T:=0 To 360 Do
  24.       Begin
  25.         SinT[T]:=Round(Sin(T*Pi/180)*127);
  26.         CosT[T]:=Round(Cos(T*Pi/180)*127);
  27.       End;
  28.   End;
  29.  
  30. {Paint a vertrical line on the Y}
  31. Procedure VLine(Y:Integer;Col:Byte);Assembler;
  32.     Asm
  33.         Mov Ax,0a000h           {Ax = screen segment}
  34.         Mov Es,Ax               {Es = Ax}
  35.         Mov Ax,320              {Ax = 320}
  36.         Mul Y                   {Ax = 320 * Y}
  37.         Mov Di,Ax               {Di = Ax}
  38.         Mov Al,Col              {Al = Col}
  39.         Mov Ah,Col              {Ah = Col}
  40.         Mov Cx,160              {Cx = 160}
  41.         Rep StoSw               {[Es:Di] = Al;[Es:Di+1] = Ah;Inc Di,2}
  42.     End;
  43.  
  44. {Draw one line from Where Y1 to Where1 Y}
  45. Procedure DrawVLine(Y,Y1:Integer;Var Where,Where1);Assembler;
  46. Asm
  47.     Cmp Y1,199                  {Checking Ranges On Y1}
  48.     Ja @Exit
  49.     Cmp Y,199                   {Checking Ranges On Y}
  50.     Ja @Exit
  51.     Push Ds                     {Saving DS}
  52.     Lds Si,Where                {[Ds:Si] = Where}
  53.     Mov Ax,320                  {Ax = 320}
  54.     Mul Y                       {Ax = Y * 320}
  55.     Add Si,Ax                   {Si = Ax}
  56.     Les Di,Where1               {[Es:Di] = Where1}
  57.     Mov Ax,320                  {Ax = 320}
  58.     Mul Y1                      {Ax = Y1 * 320}
  59.     Add Di,Ax                   {Di = Ax}
  60.     Mov Cx,160                  {Cx = 160}
  61.     Rep MovSw                   {[Es:Di] = [Ds:Si];Inc Di,2;Inc Si,2;*320}
  62.     Pop Ds                      {Restore Ds}
  63. @Exit:
  64. End;
  65. Begin
  66.     {Set Mode}
  67.     New(Pic);
  68.     MakeSinCos;
  69.     SetMode;
  70.     T:=0;
  71.     T1:= 0;
  72.     {Load Picture}
  73.     LoadCel('..\sea.Cel',Pic^,Pal);
  74.     {Put Pal}
  75.     ShowPal(Pal);
  76.     VLine(9,54);
  77.     VLine(181,54);
  78.     Repeat
  79.         For Y:=10 To 180 Do
  80.         Begin
  81.             T:=T+Waves;
  82.             T1 := (SinT[T mod 360]*SinWaves) Div 128;
  83.             DrawVLine(Y+T1,Y,Pic^,Mem[$a000:0000]);
  84.         End;
  85.         T:=T - 170*Waves;
  86.     Until(Port[$60]=1);
  87.  
  88. End.